# import sqlite3
# import random


# def simulate_model_output():
#         # 模拟模型输出
#         target_class = '俄罗斯士兵'
#         confidence = 0.9337
#         x_center = 0.45
#         y_center = 0.55
#         width = 0.2
#         height = 0.3

#         xmin = x_center - width / 2
#         ymin = y_center - height / 2
#         xmax = x_center + width / 2
#         ymax = y_center + height / 2

#         return {
#             'image_path': "00037.jpg",
#             'total_targets': 5,
#             'time_used': "0.025 s",
#             'target_selection_items': ["全部", "士兵", "平民", "车辆"],
#             'detection_name': f"检测名称：{target_class}",
#             'detection_conf': f"置信度：{confidence * 100:.2f}%",
#             'xmin': xmin,
#             'ymin': ymin,
#             'xmax': xmax,
#             'ymax': ymax,
#             'target_class': target_class,  # 保留原有的目标类别信息
#             'confidence': confidence,  # 保留原有的置信度信息
#             'x_center': x_center,  # 保留原有的中心点X坐标信息
#             'y_center': y_center,  # 保留原有的中心点Y坐标信息
#             'width': width,  # 保留原有的框宽度信息
#             'height': height,  # 保留原有的框高度信息
#             'detect_time': '2023-10-01 12:34:56',  # 保留原有的检测时间信息
#             'locate_time': '2023-10-01 12:35:00',  # 保留原有的定位时间信息
#         }


# def insert_detection_data(media_id, model_output):
#     conn = sqlite3.connect('military_detection.db')
#     cursor = conn.cursor()

#     # 插入检测数据到 detection 表
#     cursor.execute('''
#         INSERT INTO detection (media_id, file_det_name, target_class, precision, detect_time, locate_time, x_center, y_center, width, height)
#         VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
#     ''', (
#         media_id,
#         'detected_image.jpg',  # 检测后的图片名称
#         model_output['target_class'],
#         model_output['confidence'],
#         model_output['detect_time'],
#         model_output['locate_time'],
#         model_output['x_center'],
#         model_output['y_center'],
#         model_output['width'],
#         model_output['height']
#     ))

#     conn.commit()
#     conn.close()


# def get_fake_data():
#     """生成模拟的表格数据"""
#     fake_data = []  # 模拟实际数据
#     for i in range(10):  # 这里假设我们有10条数据
#         fake_data.append({
#             'path': f"/images/image{i}.jpg",
#             'id': str(random.randint(1000, 9999)),
#             'type': random.choice(["乌克兰士兵", "俄罗斯士兵"]),
#             'conf': f"{random.uniform(0.7, 0.99):.2f}",
#             'coords': f"xmin:{random.randint(100, 500)},ymin:{random.randint(100, 500)},xmax:{random.randint(100, 500)},ymax:{random.randint(100, 500)}"
#         })
#     return fake_data